using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class Universe : EveProperty
    {
        private string universeName;
        private double x, y, z;
        private double xMax, yMax, zMax;
        private double xMin, yMin, zMin;
        private double radius;

        private Vector location;
        private Vector minimum;
        private Vector maximum;

        public string Name 
        { 
            get { return universeName; } 
        }
        public Vector Location
        {
            get
            {
                if (location == null)
                    location = new Vector(x, y, z);
                return location;
            }
        }
        public Vector Minimum
        {
            get
            {
                if (minimum == null)
                    minimum = new Vector(xMin, yMin, zMin);
                return minimum;
            }
        }
        public Vector Maximum
        {
            get
            {
                if (maximum == null)
                    maximum = new Vector(xMax, yMax, zMax);
                return maximum;
            }
        }
        public double Radius
        {
            get { return radius; }
        }
        internal Universe(DbDataRow dr)
            : base(dr.Database, EvePropertyType.Universe, dr["universeID"])
        {
            Fill(dr);
        }
        internal Universe(Database db, int id)
            : base(db, EvePropertyType.Universe, id)
        {
            Fill(db.ExecuteSingle("SELECT * FROM mapUniverse WHERE universeID=" + id));
        }

        private void Fill(DbDataRow dr)
        {
            universeName = dr["universeName"];
            x = dr["x"];
            y = dr["y"];
            z = dr["z"];
            xMin = dr["xMin"];
            yMin = dr["yMin"];
            zMin = dr["zMin"];
            xMax = dr["xMax"];
            yMax = dr["yMax"];
            zMax = dr["zMax"];
            radius = dr["radius"];
        }

    }
}
